<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link th:href="@{/css/style.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/font-awesome.css}" rel="stylesheet">
    <link th:href="@{/css/animate.css}" rel="stylesheet">
    <link th:href="@{/css/plugins/toastr/toastr.min.css}" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
</head>
<body class="gray-bg">
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                <h5 class="logo-name">h</h5>
            </div>
            <h3>欢迎使用系统</h3>
            <form class="m-t" role="form" autocomplete="off">
                <div class="form-group">
                    <input type="text" class="form-control" id="username" name="username"  placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码" required="">
                </div>
                <button type="button" class="btn btn-primary block full-width m-b">登 录</button>
            </form>
        </div>
    </div>

    <!-- 全局js -->
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/plugins/toastr/toastr.min.js}"></script>
    <script th:src="@{/js/plugins/toastr/toastr.tool.js}"></script>
    <script th:inline="javascript">
        $('.btn-primary').click(function(){
            var username = $('#username').val();
            var password = $('#password').val();
            $.ajax({
                type:'post',
                url:[[${ctx}]]+"/login",
                cache: false,
                data:{username:username,password:password},
                dataType:'json',
                success:function(data){
                    if(data.code!=200){
                        showMsg(data.msg,'warning')
                    }else{
                        var redirect_url = data.result;
                        window.location.href = [[${ctx}]]+redirect_url;
                    }
                }
            })
        })

    </script>
</body>
</html>
